package c.j.a.d.b.i.a;

import com.ss.android.socialbase.downloader.g.e;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/* compiled from: DownloadConnectionPool */
public class a {
    public final Map<String, d> a = new HashMap();
    public final Map<String, e> b = new LinkedHashMap(3);

    /* compiled from: DownloadConnectionPool */
    public static final class b {
        public static final a a = new a(null);
    }

    public a(a aVar) {
    }

    public d a(String str, List<e> list) {
        d dVar;
        synchronized (this.a) {
            dVar = (d) this.a.remove(str);
        }
        if (dVar != null) {
            if (c.j.a.d.b.n.a.x(dVar.b, list)) {
                try {
                    synchronized (dVar.f) {
                        if (dVar.h && dVar.c == null) {
                            dVar.f.wait();
                        }
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                if (dVar.g() && dVar.g) {
                    return dVar;
                }
            }
            try {
                dVar.c();
            } catch (Throwable unused) {
            }
        }
        return null;
    }
}
